<Query Kind="Statements">
  <Namespace>System.Net.Sockets</Namespace>
  <Namespace>System.Net</Namespace>
  <Namespace>System.Threading.Tasks</Namespace>
</Query>

Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

_socket.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6000));

_socket.Close();

await Task.Delay(100);

_socket.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6000));

_socket.Close();